package com.mingyizhudao.app.view.mine;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import com.mingyizhudao.app.R;
import com.mingyizhudao.app.utils.Constants;
import com.mingyizhudao.app.utils.IntentHelper;
import com.mingyizhudao.app.view.MYBaseActivity;
import com.mingyizhudao.app.view.WebViewActivity;

public class CommonProblemActivity extends MYBaseActivity{
	private WebView advertise_webview;
	private ProgressBar progressBar;
	private String actionUrl = "http://m.mingyizhudao.com/mobile/user/commonProblem/header/0/app/0";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_common_problem);
		progressBar = (ProgressBar) findViewById(R.id.progress_bar);

		advertise_webview = (WebView) findViewById(R.id.advertise_webview);
		advertise_webview.setHorizontalScrollBarEnabled(false);
		advertise_webview.setVerticalScrollBarEnabled(false);
		//填充webview
		advertise_webview.setNetworkAvailable(true);
		advertise_webview.getSettings().setJavaScriptEnabled(true);
		advertise_webview.getSettings().setDefaultTextEncodingName("utf-8");

		advertise_webview.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				//view.loadUrl(url);
				IntentHelper.getInstance(activity).gotoActivityWithURL(WebViewActivity.class, url);
				return true;
			}

		});
		advertise_webview.setWebChromeClient(new WebChromeClient() {
			@Override
			public void onProgressChanged(WebView view, int progress) {
				progressBar.setProgress(progress);
				if (progress >= 100) {
					progressBar.setVisibility(View.GONE);
				}
			}
		});

		advertise_webview.loadUrl(actionUrl);
	}

	@Override
	public void initHeaderView() {
		setTopViewBg(R.color.actionbar_bg_color);
		initBackView(R.drawable.left_back_white_icon, 0, new OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		setTitleViewValue(0, 0, R.color.white);
		setTitleViewValue("常见问题");
	}


}
